﻿using System;
using System.ComponentModel;

namespace GDM.Hogar.Soporte.Helpers
{
    public static class EnumExtension
    {
        public static string Descripcion(this Enum en)
        {
            var tipo = en.GetType();
            var memInfo = tipo.GetMember(en.ToString());
            if (memInfo.Length > 0)
            {
                var attrs = memInfo[0].GetCustomAttributes(
                    typeof(DescriptionAttribute),
                    false);
                if (attrs.Length > 0)
                    return ((DescriptionAttribute)attrs[0]).Description;
            }

            return en.ToString();
        }
    }
}